<!-- 报录比 -->
<template>
	<view class="hotSchool">
		<view class="contents">
			<image class="top-bg" src="https://aihelp.oss-cn-hangzhou.aliyuncs.com/public/base/2023/10/16/c5d383fcd8d444498e91ded472361dd9.png" mode="widthFix"></image>
			<view class="tableBox">
				<wyb-table ref="table" :headers="type=='school'?headers:headers2" :contents="tableData" :url-col="urlCol" width="100%" link-color="#FDE080" border-color="#fafafa" @onCellClick="cellClick"/>
			</view>
		</view>		
	</view>
</template>

<script>
	import { getSchoolRate,getRateByMajor} from '@/api/toolbox.js';
	import wybTable from '@/pages/toolbox/components/wyb-table/wyb-table.vue'
	export default {
		components: {
			wybTable,
		},
		data() {
			return {
				searchParam: {
					// pageNum: 1,
					// pageSize: 20,
				},
				code: '',
				type: 'school',//school、学校报录比，major、专业报录比
				tableData: [],
				urlCol: [{
					type: 'route',
					key: 'url'
				}, {
					type: 'http',
					key: 'link'
				}],
				headers: [
					{
						label: '年份',
						key: 'year',
						width: 80
					},
					{
						label: '招生人数',
						key: 'enrollStudentNumber',
						width: 90
					},
					{
						label: '录取人数',
						key: 'enrollNumber',
						// width: 130
					},
					{
						label: '第一志愿',
						key: 'applyNumber',
						// width: 200,
					},
					{
						label: '保研人数',
						key: 'recommendNumber',
						// width: 200,
					},
					{
						label: '调剂人数',
						key: 'adjustNumber',
						// width: 200,
					},
				],
				headers2: [
					{
						label: '年份',
						key: 'year',
						width: 80
					},
					{
						label: '招生人数',
						key: 'enrollStudentNumber',
						width: 90
					},
					{
						label: '录取人数',
						key: 'enrollNumber',
						// width: 130
					},
					{
						label: '第一志愿',
						key: 'applyNumber',
						// width: 200,
					},
					{
						label: '推免人数',
						key: 'recommendNumber',
						// width: 200,
					},
					{
						label: '调剂人数',
						key: 'adjustNumber',
						// width: 200,
					},
				]
			}
		},
		onLoad(options){
			// console.log(options);
			this.code  = options.code;
			this.type = options.type;
			if(options.type == 'school'){
				uni.setNavigationBarTitle({
				    title: options.name+' 历史报录比'
				})
				this.getSchoolRate();
			}
			if(options.type == 'major'){
				uni.setNavigationBarTitle({
				    title: options.name+' 历史报录比'
				})
				this.getRateByMajor();
			}
		},
		methods: {
			// 单元格点击事件
			cellClick(e){
				// console.log(e);
				// uni.navigateTo({
				// 	url: '/pages/toolbox/chooseMajor/hotList/components/reporting/reporting'
				// })
			},
			getSchoolRate(){
				getSchoolRate({schoolCode: this.code}).then(res=>{
					// console.error(res)
					if(res.code === 100000){
						this.tableData = res.data;
					}
				})
			},
			getRateByMajor(){
				getRateByMajor({majorCode: this.code}).then(res=>{
					// console.error(res)
					if(res.code === 100000){
						this.tableData = res.data;
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.top-bg{
		width: 100%;
		height: 280rpx;
		// background: rgba(114,94,237,0.8);
		border-radius: 100rpx;
		border-top-left-radius: 0px;
		border-top-right-radius: 0px;
	}
	
	.tableBox{
		margin: 0 20rpx;
		position: absolute;
		margin-top: -80rpx;
	}
</style>